<template>
	<view class="search">
		<view class="index_top">
			<view :style="{ height: computedHeight,marginTop:computedTop}">
				<view class="index_top_city flex" @click="Back">
					<image src="../../static/search/back.png" class="bfbimages"></image>
				</view>
				<view class="index_top_inp">
					<u--input placeholder="搜索商家名称" prefixIcon="search" prefixIconStyle="font-size: 14px;color: #999999"
						shape="circle" border="none" @confirm='confirm' v-model="input"></u--input>

					<view class="index_top_inp_btn">搜索</view>
				</view>
			</view>
		</view>

		<view class="search_top">
			<view class="search_top_title">
				<text>搜索历史</text>
				<view class="flex">
					<image src="../../static/search/delete.png" class="bfbimages"></image>
				</view>
			</view>

			<view class="search_top_list">
				<view v-for="(item,index) in 10" :key="index">龙虾</view>
				<view>舒肤佳石榴味</view>
			</view>
		</view>

		<view class="search_top">
			<view class="search_top_title">
				<text>热门推荐</text>
				<view class="flex"></view>
			</view>

			<view class="index_body_list" v-for="(itex,index) in 3" :key="index">
				<view class="index_body_list_one">
					<view>
						<view class="icon flex">
							<image src="../../static/index/cj.png" class="bfbimages"></image>
						</view>
						<text>发了红包赶紧抢！！！</text>
					</view>
					<view>
						<text style="font-size: 28rpx;color: #999999;font-weight: 500;">5.12km</text>
						<view class="icon flex" style="width: 28rpx;height: 28rpx;margin-left: 10rpx;margin-right: 0;">
							<image src="../../static/index/cj.png" class="bfbimages"></image>
						</view>
					</view>
				</view>
				<view class="index_body_list_two">
					<view class="index_body_list_two_For" v-for="(index,item) in 4" :key="index">
						<view class="index_body_list_two_For_one">
							<view>
								<view class="index_body_list_two_For_one_icon flex"></view>
								<view>
									<!-- 红色背景时 -->
									<text>现金红包</text><br />
									<!-- 黄色背景时 -->
									<!-- <text style="color: #000000;">现金红包</text><br /> -->
									<!-- <text style="color: #FE4926;font-size: 24rpx;">未使用</text> -->
									<!-- 灰色背景时 -->
									<!-- <text style="color: #666666;">优惠卷</text> -->
								</view>
							</view>
							<view>
								<view class="zfzq">转发赚钱</view>
								<!-- <view class="yjs">已结束</view> -->
								<text>剩余20</text>
							</view>
						</view>
						<image src="../../static/index/hb_red.png" class="bfbimages"></image>
						<!-- <image src="../../static/index/hb_yellow.png" class="bfbimages"></image> -->
						<!-- <image src="../../static/index/hb_gray.png" class="bfbimages"></image> -->
					</view>
				</view>



			</view>
		</view>

		<view class="index_body_map">
			<view class="index_body_map_title">
				<view class="index_body_map_title_t">红包地图</view>
				<view class="index_body_map_title_x"></view>
			</view>

			<view class="index_body_map_show">
				<map id="myMap" style="width:100%;height:100%;" :markers="markers" @markertap="onMarkerTap"
					:latitude="latitude" :longitude="longitude" :scale="scale"></map>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuButtonInfo: null,
				latitude: 34.747201, //纬度
				longitude: 113.625000, //经度
				scale: 14, //地图缩放程度
				markers: [],
			}
		},
		computed: {
			computedHeight() {
				if (this.menuButtonInfo) {
					return `${this.menuButtonInfo.height * 2 - 6}px`;
				}
				return '0px';
			},
			computedTop() {
				if (this.menuButtonInfo) {
					return `${this.menuButtonInfo.top - 12}px`;
				}
				return '0px';
			},
		},
		onLoad() {
			const info = uni.getMenuButtonBoundingClientRect();
			this.menuButtonInfo = info;
		},
		methods: {
			confirm() {
				console.log(this.input);
			},
			onMarkerTap(e) {
				console.log('点击了', e);
				// console.log(e.markerId,'markerId-markerId-markerId');
				const markerId = e.markerId;
				const clickedMarker = this.markers.find(marker => marker.id === markerId);
				// console.log(clickedMarker.id, '点击的对应id');
				const matchedData = this.MenDian.find(item => item.id === clickedMarker.id);
				// console.log(matchedData, '匹配到的数据');
				const index = this.MenDian.indexOf(matchedData);
				if (index > 0) {
					this.MenDian.splice(index, 1);
					this.MenDian.unshift(matchedData);
				}

			},
			Back() {
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss">
	.search {
		width: 100vw;
		min-height: 100vh;
		background-color: #FFFFFF;
		float: left;

		.index_top {
			width: 100%;
			height: 220rpx;
			float: left;
			background-color: #FFFFFF;
		}

		.index_top>view:nth-child(1) {
			width: 100%;
			display: flex;
			align-items: center;

			.index_top_city {
				width: 44rpx;
				height: 44rpx;
				margin-left: 30rpx;
			}

			.index_top_city>view:nth-child(1) {
				max-width: 128rpx;
			}

			.index_top_city>view:nth-child(2) {
				width: 18rpx;
				height: 18rpx;
				margin-left: 10rpx;
			}

			.index_top_inp {
				width: 434rpx;
				height: 80rpx;
				background: #F7F7F7;
				border-radius: 50rpx;
				margin-left: 15rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-left: 10rpx;
				padding-right: 10rpx;
			}

			.index_top_inp_btn {
				width: 116rpx;
				height: 64rpx;
				background: linear-gradient(270deg, #FE4624 0%, #FF8143 100%);
				border-radius: 40rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 64rpx;
			}
		}

		.index_top>view:nth-child(2) {
			width: 710rpx;
			height: 300rpx;
			border-radius: 20rpx;
			margin: 21rpx auto 0;
			overflow: hidden;
		}

		.search_top {
			width: 100%;
			float: left;

			.search_top_title {
				width: 710rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin: 0 auto;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 30rpx;
				color: #999999;
			}

			.search_top_title>view {
				width: 35rpx;
				height: 35rpx;
			}

			.search_top_list {
				width: 710rpx;
				height: auto;
				margin: 10rpx auto 0;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
				display: flex;
				align-items: center;
				flex-wrap: wrap;
			}

			.search_top_list>view {
				min-width: 116rpx;
				max-width: 270rpx;
				height: 48rpx;
				background: #F2F2F2;
				border-radius: 30rpx;
				text-align: center;
				line-height: 48rpx;
				margin-right: 20rpx;
				margin-bottom: 20rpx;
				padding-left: 5rpx;
				padding-right: 5rpx;
			}

			.index_body_list {
				width: 690rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 3rpx 25rpx 0rpx rgba(88, 64, 64, 0.09);
				border-radius: 20rpx;
				margin: 15rpx auto 0;
				padding: 20rpx 20rpx;

				.index_body_list_one {
					width: 100%;
					height: 32rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #333333;
				}

				.index_body_list_one>view:nth-child(1) {
					width: 75%;
					height: 100%;
					display: flex;
					align-items: center;
				}

				.icon {
					width: 32rpx;
					height: 32rpx;
					margin-right: 10rpx;
				}

				.index_body_list_one>view:nth-child(2) {
					width: 25%;
					height: 100%;
					display: flex;
					align-items: center;
					justify-content: flex-end;
				}

				.index_body_list_two {
					width: 97%;
					height: auto;
					display: flex;
					align-items: center;
					justify-content: space-between;
					flex-wrap: wrap;
					margin: 5rpx auto 0;

					.index_body_list_two_For {
						width: 325rpx;
						height: 90rpx;
						border-radius: 10rpx;
						overflow: hidden;
						margin-bottom: 6rpx;
						margin-top: 6rpx;
						position: relative;

						.index_body_list_two_For_one {
							width: 90%;
							display: flex;
							align-items: center;
							justify-content: space-between;
							position: absolute;
							left: 50%;
							top: 50%;
							transform: translate(-50%, -50%);
							color: #FFFFFF;
							font-family: PingFang SC, PingFang SC;
							font-weight: bold;
							font-size: 32rpx;
							color: #FFFFFF;
						}

						.index_body_list_two_For_one>view:nth-child(1) {
							width: 60%;
							height: 100%;
							display: flex;
							align-items: center;
						}

						.index_body_list_two_For_one>view:nth-child(2) {
							width: 40%;
							height: 100%;
							display: flex;
							align-items: center;
							justify-content: flex-end;
							flex-wrap: wrap;
							text-align: right;
							font-weight: 500;
							font-size: 24rpx;
						}

						.zfzq {
							width: 96rpx;
							height: 24rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 24rpx;
							color: #FFED31;
							line-height: 24rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;
							border-radius: 4rpx;
							border: 1rpx solid #FFED31;
						}

						.yjs {
							width: 80rpx;
							height: 32rpx;
							background: rgba(102, 102, 102, 0.2);
							border-radius: 4rpx 4rpx 4rpx 4rpx;
							border: 1rpx solid #666666;
							display: flex;
							align-items: center;
							justify-content: center;
							width: 72rpx;
							height: 24rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 24rpx;
							color: #666666;
							line-height: 24rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;
						}

						.index_body_list_two_For_one_icon {
							width: 21rpx;
							height: 24rpx;
							background-color: green;
							overflow: hidden;
							margin-right: 10rpx;
						}
					}
				}
			}
		}

		.index_body_map {
			width: 100%;
			height: 500rpx;
			margin: 20rpx auto 0;
			float: left;

			.index_body_map_title {
				width: 145rpx;
				height: 36rpx;
				position: relative;
				line-height: 36rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #333333;
				margin-left: 22rpx;

				.index_body_map_title_t {
					width: 100%;
					height: 100%;
					position: absolute;
					left: 0;
					right: 0;
					top: 0;
					bottom: 0;
					z-index: 5;
				}

				.index_body_map_title_x {
					width: 90%;
					height: 6rpx;
					position: absolute;
					bottom: 0;
					left: 50%;
					z-index: 4;
					transform: translate(-50%, 0);
					background: linear-gradient(to right, red, pink);
				}
			}

			.index_body_map_show {
				width:710rpx;
				height: 395rpx;
				border-radius: 20rpx;
				overflow: hidden;
				margin: 20rpx auto 0;
			}
		}
	}
</style>